<template>
  <el-dialog v-if="visible" :title="info.title" :visible.sync="visible" center width="460px" :before-close="handleCancel">
    <el-form ref="formDate" label-suffix=":" label-width="100px" :rules="rules" :model="form">
      <el-row>
        <!-- <el-col :span="24">
          <el-form-item label="对讲机型号" prop="model">
            <el-input v-model="form.model" size="small" clearable />
          </el-form-item>
        </el-col> -->
        <el-col :span="24">
          <el-form-item label="对讲机号码" prop="number">
            <el-input v-model="form.number" size="small" clearable />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item style="width: 100%" label="领用人" prop="su_id">
            <StaffSelect v-model="form.su_id" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="领用日期" prop="receive_time">
            <el-date-picker
              v-model="form.receive_time"
              type="date"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              size="small"
              clearable
              style="width: 100%"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="使用工地" prop="addr">
            <el-input v-model="form.addr" size="small" clearable />
          </el-form-item>
        </el-col>
        <el-col v-if="this.info.type === 'edit'" :span="24">
          <el-form-item label="状态" prop="state">
            <el-select
              v-model="form.state"
              size="small"
              allow-create
              remote
              filterable
              style="width: 100%"
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in states"
                :key="item.value"
                :label="item.value"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="form.remark" type="textarea" :rows="4" size="small" clearable />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="fr mt10">
            <el-button size="small" @click="handleCancel()">取 消</el-button>
            <el-button type="primary" size="small" @click="handleEdit()">保 存</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
import { addWalkieTalkie, updWalkieTalkie } from '@/api/personnel/walkietalkie'
import StaffSelect from '@/myComponents/StaffSelect'
import form from '@/utils/form'

export default {
  components: { StaffSelect },
  extends: form,
  props: {
    reqAdd: {
      default: addWalkieTalkie,
      type: Function
    },
    reqUpd: {
      default: updWalkieTalkie,
      type: Function
    }
  },
  data() {
    return {
      states: [{ value: '使用中' }, { value: '闲置' }],
      rules: {
        // model: [{ required: true, trigger: 'blur', message: '对讲机型号不可为空' }],
        number: [{ required: true, trigger: 'blur', message: '对讲机号码不可为空' }],
        su_id: [{ required: true, trigger: 'blur', message: '领用人不可为空' }],
        state: [{ required: true, trigger: 'blur', message: '状态不可为空' }],
        receive_time: [{ required: true, trigger: 'blur', message: '领用日期不可为空' }],
        addr: [{ required: true, trigger: 'blur', message: '使用工地不可为空' }]
      }
    }
  },
  watch: {
    visible(val) {
      if (val) {
        this.form = this.info.edit
      }
    },
    getData: {
      type: Function,
      default: function() {}
    }
  },
  mounted() {
  },
  methods: {
  }
}
</script>

<style>

</style>
